package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.oa.FlowHandleStatusEnum;
import com.dt.platform.constants.enums.oa.SealStatusEnum;
import com.dt.platform.constants.enums.oa.VehicleHandleStatusEnum;
import com.dt.platform.domain.oa.SealApply;
import com.dt.platform.domain.oa.meta.SealApplyMeta;
import com.dt.platform.domain.oa.meta.SealInfoMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.SealApplyPageController;
import com.dt.platform.proxy.oa.SealApplyServiceProxy;
import com.github.foxnic.api.bpm.IntegrateMode;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.hrm.Organization;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;

public class SeaApplyGtr extends BaseCodeGenerator {

    //DownFileGtr
    public SeaApplyGtr() {
        super(OaTables.OA_SEAL_APPLY.$TABLE,"811710244936744961");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"user","user","user");

        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"typeDict","typeDict","typeDict");

        cfg.view().field(OaTables.OA_SEAL_APPLY.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_SEAL_APPLY.NAME).search().fuzzySearch();

        cfg.bpm().form("oa_seal_apply");
        cfg.bpm().integrate(IntegrateMode.FRONT);
        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_SEAL_APPLY.STATUS,
                        OaTables.OA_SEAL_APPLY.SEAL_TYPE,
                }
        );

        cfg.view().field(OaTables.OA_SEAL_APPLY.SEAL_TYPE)
                .basic().label("印章类型")
                .form().validate().required().form().selectBox().queryApi(DictItemServiceProxy.QUERY_LIST+"?dictCode=oa_seal_type")
                .paging(false).filter(false).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(SealApplyMeta.TYPE_DICT).muliti(false);

        cfg.view().field(OaTables.OA_SEAL_APPLY.CONTENT)
                .form().validate().required().form().textArea().height(120);

        cfg.view().field(OaTables.OA_SEAL_APPLY.NAME).table().disable(true);
        cfg.view().field(OaTables.OA_SEAL_APPLY.SEAL_ID).table().disable(true);
        cfg.view().field(OaTables.OA_SEAL_APPLY.UPDATE_BY).table().disable(true);

        cfg.view().field(OaTables.OA_SEAL_APPLY.STATUS).form().
                label("办理状态").selectBox().enumType(FlowHandleStatusEnum.class);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);


        cfg.view().form().labelWidth(70);
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth);;

        cfg.view().field(OaTables.OA_SEAL_APPLY.USER_ID).table().fillBy("user","name");
        cfg.view().field(OaTables.OA_SEAL_APPLY.USER_ID).form()
                .button().chooseEmployee(true);

        cfg.view().form().addGroup(null,
                new Object[] {
                    //    OaTables.OA_SEAL_APPLY.NAME,
                        OaTables.OA_SEAL_APPLY.SEAL_TYPE,
                },
                new Object[] {
                        OaTables.OA_SEAL_APPLY.USER_ID,
                }
        );

        cfg.view().form().addGroup(null,

                new Object[] {
                        OaTables.OA_SEAL_APPLY.CONTENT,
                }
        );

        cfg.view().form().addJsVariable("CUR_EMP_ID","[[${curEmpId}]]","curEmpId");
        cfg.view().form().addJsVariable("CUR_USER_NAME","[[${curUserName}]]","curUserName");


        cfg.view().list().disableBatchDelete();
        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setBpmEventAdaptor(WriteMode.IGNORE)
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        SeaApplyGtr g=new SeaApplyGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
     //   g.generateMenu(SealApplyServiceProxy.class, SealApplyPageController.class);
    }

}
